$().ready(function(){
	if($("input[name='txtID']").val() == ""){		
		$("#savecomment").attr('disabled', 'disabled');
	}else{
		$("#savecomment").removeAttr('disabled');
	}
	
	if($("input[name='txtVPSIP']").val() == ""){
		$("#btnSubmitServerVPS").attr('disabled', 'disabled');
	}
	
	if($("#cboHosting").val() == ""){
		$("#sbmServerLog").attr('disabled', 'disabled');
	}	

	
	$("#savecomment").click(function(){
		var content = tinyMCE.activeEditor.getContent(); // get the content
    	$('#myarea1').val(content); // put it in the textarea
		
		if($('#myarea1').val() == "" || $('#myarea1').val() == null){
			$("#IPInfo").addClass("attendMsg");
			return false;
		}
		else if($("#IPInfo").text().indexOf("P") == 0 ){
			$("#IPInfo").addClass("attendMsg");
			return false;
		}
		
		return true;
	});	

});

$("#comment_wrapper").hide();
function enableButton(){
	if($("input[name='txtVPSIP']").val() == ""){
		$("#btnSubmitServerVPS").attr('disabled', 'disabled');
	}else{
		$("#btnSubmitServerVPS").removeAttr('disabled');
	}
	
	/*if($("#cboHosting").val() == ""){
		$("#sbmServerLog").attr('disabled', 'disabled');
	}else{
		$("#sbmServerLog").removeAttr('disabled');
	}*/
}


function deleteConfirm(){
	if(confirm('Are you sure wana delete?'))
		return true;
	else	
		return false;
}

function gotOtherServer(value){
	window.location='?module=server_log&hostid='+value;
}

function validateIPAndHostingInfor()
{
	var ipmask = /\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/;
	var hostingmask = /^(([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})$/;
	var ip = document.getElementsByName("txtVPSIP");
	var host = document.getElementsByName("txtVPSHost");
	
	if(!ipmask.test(ip[0].value)){
		alert("IP is incorrect")
		return false;
	}else if(host[0].value.length > 0){
		if(!hostingmask.test(host[0].value)){
			alert('Host is incorrect')
			return false;		
		}	
	}
	
	return true;
}
